package cn.nbt.busManage.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;

/**
 * @author lyq
 * @time 2024/6/18 19:09
 */

@Mapper
public interface BusMapper {

    @Insert("insert into bus (license_plate, model, capacity, status, last_maintenance_date, next_inspection_date, route_id) values (#{licensePlate}, #{model}, #{capacity}, #{status}, #{lastMaintenanceDate}, #{nextInspectionDate}, #{route.id})")
    void save(@Param("licensePlate") String licensePlate,
              @Param("model") String model,
              @Param("capacity") Integer capacity,
              @Param("status") Integer status,
              @Param("lastMaintenanceDate") LocalDateTime lastMaintenanceDate,
              @Param("nextInspectionDate") LocalDateTime nextInspectionDate,
              @Param("routeId") Integer routeId);

    @Delete("delete from bus_driver where bus_driver.driver_id = #{driverId}")
    void deleteBusDriver(@Param("driverId") Integer driverId);

    @Delete("delete from bus_driver where bus_driver.bus_id = #{busId}")
    void deleteBusDriverByBusId(int id);

    @Delete("delete from bus where bus.id = #{busId}")
    void deleteById(int id);

}
